from socket import *
from time import ctime

HOST = ''
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST,PORT)

tcpServer = socket(AF_INET,SOCK_STREAM)
tcpServer.bind(ADDR)
tcpServer.listen(5)

while True:
    print("wating for connection...")
    tcpClient, addr = tcpServer.accept()
    print("...connection from ",addr)
    while True:
        data = tcpClient.recv(BUFSIZ).decode()
        if not data:
            break
        tcpClient.send(('[%s] %s'% (ctime(),data)).encode())
    tcpClient.close()
tcpServer.close()